package com.yh.serviceImpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;

import com.yh.bean.BrowseRecords;
import com.yh.bean.News;
import com.yh.bean.NewsComment;
import com.yh.bean.NewsReply;
import com.yh.dao.NewsDao;
import com.yh.service.NewsDaoSer;
@Service
public class NewsDaoImol implements NewsDaoSer {
	@Autowired
	private NewsDao newsDao;
	
	@Override
	public List<News> queryNewsSer() {
		// TODO Auto-generated method stub
		
		List<News> news=newsDao.queryNews();
		
		System.out.println("返回的数据+++++++++++++++++++"+news);
		return news;
	}

	@Override
	public News queryNewsDetailss(int newdId) {
		// TODO Auto-generated method stub
		
		News news=newsDao.queryNewsDetails(newdId);
		System.out.println("返回的数据-+------------------"+news);
		return news;
	}

	@Override
	public int leaveM(NewsComment newsC) {
		// TODO Auto-generated method stub
		int leaveM=newsDao.LeaveMessage(newsC);
		if(leaveM>0){
			return 1;
		}else{
		
		return 0;
		}
	}

	@Override
	public List<NewsComment> queryComm(int news_Id) {
		// TODO Auto-generated method stub
		List<NewsComment> newsComm=newsDao.queryComment(news_Id);
		
		return newsComm;
	}

	@Override
	public int replyComm(NewsReply newsReply) {
		// TODO Auto-generated method stub
		int replyComment=newsDao.replyComment(newsReply);
		if(replyComment>0){
			return 1;
		}else{
		return 0;
		}
		}

	@Override
	public List<NewsReply> queryReply(int comId) {
		// TODO Auto-generated method stub
	List<NewsReply> queryR=newsDao.queryReplyComment(comId);
		
		return queryR;
	}

	@Override
	public int addNewss(News news) {
		// TODO Auto-generated method stub
		
		int addNEWS=newsDao.addNews(news);
		System.out.println(addNEWS);
		if(addNEWS>0){
			return 1;
		
		}else{
		return 0;
		}
		}

	@Override
	public int deleteNewss(int newsId) {
		// TODO Auto-generated method stub
		int deleteNNews=newsDao.deleteNews(newsId);
		if(deleteNNews>0){
			
			return 1;
		}else{
			return 0;
	}
		}

	@Override
	public int updateNews(int news) {
		// TODO Auto-generated method stub
		
		int updateNewss=newsDao.updateNews(news);
if(updateNewss>0){
			
			return 1;
		}else{
			return 0;
	}
		
	}

	@Override
	public int createBrowserRecords(BrowseRecords b) {
		// TODO Auto-generated method stub
		int createBrowserRecords=newsDao.createRecords(b);
if(createBrowserRecords>0){
			
			return 1;
		}else{
			return 0;
	}
	
	}

}
